import request from '@/utils/request'

// 实时监控相关
export function startDetection() {
  return request({
    url: '/api/detection/start/',
    method: 'post',
    headers: { 'Authorization': `Token ${localStorage.getItem('token')}` }
  })
}

export function stopDetection() {
  return request({
    url: '/api/detection/stop/',
    method: 'post',
    headers: { 'Authorization': `Token ${localStorage.getItem('token')}` }
  })
}

export function getDetectionStatus() {
  return request({
    url: '/api/detection/status/',
    method: 'get',
    headers: { 'Authorization': `Token ${localStorage.getItem('token')}` }
  })
}

// 图片检测相关
export function uploadImage(data) {
  return request({
    url: '/api/v1/detection/images/upload/',
    method: 'post',
    data
  })
}

export function getUserImages() {
  return request({
    url: '/api/v1/detection/images/',
    method: 'get'
  })
}

// 视频检测相关
export function uploadVideo(data) {
  return request({
    url: '/api/v1/detection/videos/upload/',
    method: 'post',
    data
  })
}

export function getUserVideos() {
  return request({
    url: '/api/v1/detection/videos/',
    method: 'get'
  })
}

export function detectVideo(data) {
  return request({
    url: '/api/v1/detection/videos/detect/',
    method: 'post',
    data
  })
}

export function getVideoDetections(videoId) {
  return request({
    url: `/api/v1/detection/videos/${videoId}/detections/`,
    method: 'get'
  })
}

// 获取实时检测数据
export function getRealtimeData() {
  return request({
    url: '/api/v1/detection/statistics/realtime/',
    method: 'get'
  })
}

// 获取视频检测历史数据
export function getVideoData() {
  return request({
    url: '/api/v1/detection/statistics/video/',
    method: 'get'
  })
}

// 获取最新实时检测数据
export function getLastRealtimeDetection() {
  return request({
    url: '/api/v1/detection/statistics/realtime/last/',
    method: 'get'
  })
}

// 获取最新视频检测数据
export function getLastVideoDetection() {
  return request({
    url: '/api/v1/detection/statistics/video/last/',
    method: 'get'
  })
} 